/*---------------------------------------------------------------------------------

	by GugloPWN

---------------------------------------------------------------------------------*/

#ifndef BLOCK_H
#define BLOCK_H

#include <nds.h>
#include <stdio.h>
#include <string.h>
#include "MD2.h"


//Rail structure
struct point{
	u8 x;
	u8 y;
	u8 z;
};

struct rail{
	point a;
	point b;
};


//Tags structure
struct tag{
	u8 x;
	u8 y;
	u8 z;
	u8 rot;
	u8 size;
	u8 paint;
};
	

//Deco object Structure
struct deco{
	u8 x;
	u8 y;
	u8 z;
	u8 rot;
	u8 type;
};


//Pole structure
struct pole{
	u8 x;
	u8 y;
	u8 z;
};


//item structure
struct item{
	u8 x;
	u8 y;
	u8 z;
	u8 type;
};



class block {

	public:

	block() {getdefaultblock();}
	block(char path[64]) {readblock(path);}
	void readblock(char path[64]);
	
	void writeblock(char path[64]);

	void getdefaultblock();
	void getnullblock();
	
	void loadblockmodel();
	
	void drawblock();
	void drawblockcolmap();
	
	//Setters and getters for the various block elements
	inline u8 getbase(int i, int j) {return base[i][j];}
	inline void setbase(int i, int j, int z) {base[i][j] = z;}
	
	inline u8 getplat(int i, int j) {return plat[i][j];}
	inline void setplat(int i, int j, int z) {plat[i][j] = z;}
	
	inline rail getrail(int i) {return rails[i];}
	inline void setrail(int i, rail newrail) {rails[i] = newrail;}
	
	inline tag gettag(int i) {return tags[i];}
	inline void settag(int i, tag newtag) {tags[i] = newtag;}
	
	inline deco getdeco(int i) {return decos[i];}
	inline void setdeco(int i, deco newdeco) {decos[i] = newdeco;}
	
	inline pole getpole(int i) {return poles[i];}
	inline void setpole(int i, pole newpole) {poles[i] = newpole;}
	
	inline item getitem(int i) {return items[i];}
	inline void setitem(int i, item newitem) {items[i] = newitem;}
	
	
	private:
	
	//The block elements
	u8 base[20][20];
	u8 plat[20][20];
	rail rails[16];
	pole poles[16];
	tag tags[6];
	deco decos[16];
	item items[16];
	
	//MD2 stuff
	
	int Texture[1];
	int TexturePal[1];
	int textsize;
	MD2Entity Model;
	bool ModelEnable;
	
};


#endif


